<template>
    <div style="padding:1rem;">
        <div style="clear:both; height:0px; overflow: hidden;">&nbsp;</div>

        <el-form label-width="100px" label-position="left">
            <template v-for="(value, key) in builder">
                
                <el-form-item :label="value">
                    <el-input :size='size' v-model="data[key]" style="width:220px">
                    </el-input>
                    <el-button :size='size' type="primary" @click="buildNo(key)">
                        构建
                    </el-button>
                </el-form-item>
            </template>
        </el-form>
    </div>
</template>

<script type="text/javascript">
module.exports = {
    data: function() {
        return {       
            data: {
                vinNo: '',
                ms: ''
            },
            size: 'mini',
            builder: {
                'vinNo': '车架号',
                'ms': '毫秒'
            }
        }
    },
    methods: {
        buildLocalNo(type) {
            if('ms' == type) {
                return new Date().getTime();
            }
            return 'unkown';
        },
        buildNo(type) {
            if('ms' == type) {
                var no = this.buildLocalNo(type);
                this.data[type] = no;
                return;
            }
            var param = {
                type: type
            };
            var url = Config.space + 'tool/buildNo';
            $.post(url, param, (result) => {
                this.data.vinNo = result;
            });
        }
    }
}
</script>